/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PMPreviewPanel.java
 *
 * Created on 24/Out/2012, 11:22:01
 */
package chatclient;

import java.awt.Color;

/**
 *
 * @author Old
 */
public class PMPreviewPanel extends javax.swing.JPanel {
    
    private ChatSDClientView pai;
    private int pmId;
    private String de;
    private String texto;
    private String data;
    private int idx;

    /** Creates new form PMPreviewPanel */
    public PMPreviewPanel(ChatSDClientView oPai) {
        this.pai = oPai;
        initComponents();
    }

    public PMPreviewPanel(ChatSDClientView pai, int pmId, String de, String texto, String data, int idx) {
        this.pai = pai;
        this.pmId = pmId;
        this.de = de;
        this.texto = texto;
        this.data = data;
        this.idx = idx;
        initComponents();
        deLabel.setText(de);
        textLabel.setText(texto);
        dataLabel.setText(data);
    } 
    
    
    
    public void setSelected(boolean isSelected) {
        if (isSelected) {
            this.setBackground(new Color(153, 204, 255));
            this.setForeground(Color.white);
            deLabel.setBackground(new Color(153, 204, 255));
            deLabel.setForeground(Color.white);
            textLabel.setBackground(new Color(153, 204, 255));
            textLabel.setForeground(Color.white);
            dataLabel.setBackground(new Color(153, 204, 255));
            dataLabel.setForeground(Color.white);
        } else {
            this.setBackground(Color.white);
            this.setForeground(Color.black);
            deLabel.setBackground(Color.white);
            deLabel.setForeground(Color.black);
            textLabel.setBackground(Color.white);
            textLabel.setForeground(Color.black);
            dataLabel.setBackground(Color.white);
            dataLabel.setForeground(Color.black);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        deLabel = new javax.swing.JLabel();
        textLabel = new javax.swing.JLabel();
        dataLabel = new javax.swing.JLabel();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(chatclient.ChatSDClientApp.class).getContext().getResourceMap(PMPreviewPanel.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        setMaximumSize(new java.awt.Dimension(800, 25));
        setMinimumSize(new java.awt.Dimension(800, 25));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(800, 25));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                formMouseReleased(evt);
            }
        });

        deLabel.setText(resourceMap.getString("deLabel.text")); // NOI18N
        deLabel.setName("deLabel"); // NOI18N

        textLabel.setText(resourceMap.getString("textLabel.text")); // NOI18N
        textLabel.setName("textLabel"); // NOI18N

        dataLabel.setText(resourceMap.getString("dataLabel.text")); // NOI18N
        dataLabel.setName("dataLabel"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(deLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dataLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(deLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(textLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(dataLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
// TODO add your handling code here:
    pai.setSelectedPM(this.idx);
}//GEN-LAST:event_formMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel dataLabel;
    private javax.swing.JLabel deLabel;
    private javax.swing.JLabel textLabel;
    // End of variables declaration//GEN-END:variables
}
